package com.telit.uav.service.impl;

import com.telit.uav.dao.AppUavTrackDetailDao;
import com.telit.uav.dao.CommUavDao;
import com.telit.uav.entity.AppUavTrackDetail;
import com.telit.uav.entity.CommUav;
import com.telit.uav.service.AppUavTrackDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @author zhouyu
 * @description 无人机实时轨迹接口
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AppUavTrackDetailServiceImpl implements AppUavTrackDetailService {
    @Autowired
    private AppUavTrackDetailDao appUavTrackDetailDao;

    @Autowired
    private CommUavDao commUavDao;

    @Override
    public void uploadRealTimeTrack(AppUavTrackDetail appUavTrackDetail) {
        appUavTrackDetailDao.insertSelective(appUavTrackDetail);
    }

    @Override
    public List<AppUavTrackDetail> queryUavFlyDetailBySubTaskId(Long subTaskId) {
        List<AppUavTrackDetail> list=appUavTrackDetailDao.queryUavFlyDetailBySubTaskId(subTaskId);
        list.forEach(e->{
            String uavName= e.getUavName();
            CommUav commUav=commUavDao.queryUavInfoByUavName(uavName);
            e.setDeviceMaker(commUav.getEquipmentManufacturer());
            e.setDeviceModel(commUav.getEquipmentModel());
            e.setDeviceNumber(commUav.getUavCode());
        });
        return list;
    }
}
